#!/usr/bin/env python
# -*- coding: utf-8 -*-
# @Time       : 2025/8/9 14:55
# @Author     : cfg
# @File       : secret_utils.py
# @Software   : PyCharm
# @Description: 字符串加解密.
def str2bin(s: str):
    res = []
    bin_list = list(s.encode())
    for num in bin_list:
        res.append(bin(num)[2:].zfill(8))
    return ''.join(res)


def bin2str(b):
    bin_list = [b[i:i + 8] for i in range(0, len(b), 8)]
    int_list = []
    for bin_s in bin_list:
        int_list.append(int(bin_s, 2))
    return bytes(int_list).decode()